package com.sskj.mine.ui.activity;


import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.common.util.ImgUtil;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.util.CopyUtil;
import com.sskj.lib.util.ImageUtil;
import com.sskj.mine.R;
import com.sskj.mine.R2;
import com.sskj.mine.bean.SpreadBean;
import com.sskj.mine.presenter.SpreadActivityPresenter;

import butterknife.BindView;

@Route(path = RConfig.MINE_SPREAD)//我要推广
public class SpreadActivity extends BaseActivity<SpreadActivityPresenter> {
    @BindView(R2.id.ivQRCode)
    ImageView ivQRCode;
    @BindView(R2.id.tvSave)
    TextView tvSave;
    @BindView(R2.id.tvLink)
    TextView tvLink;
    @BindView(R2.id.btCopy)
    Button btCopy;

    @Override
    protected int getLayoutId() {
        return R.layout.mine_activity_spread;
    }

    @Override
    public SpreadActivityPresenter getPresenter() {
        return new SpreadActivityPresenter();
    }

    @Override
    protected void initView() {
        setTitle(App.INSTANCE.getString(R.string.mine_spreadActivity1_j));
    }

    @Override
    protected void initData() {
        mPresenter.getData();
    }

    public void updateUI(SpreadBean data) {
        tvLink.setText(data.getUrl());
        ImageUtil.setImage(data.getQrc(), ivQRCode);
        ClickUtil.click(tvSave, () -> {
            ImgUtil.saveImageToGallery(this, ivQRCode);
        });
        ClickUtil.click(btCopy, () -> {
            CopyUtil.copy(data.getUrl());
        });
    }


}
